<?php 
require_once('config.php');
if ( (!isset($_SESSION['SESS_ID'])) && (isset($_COOKIE['id'])) && (isset($_COOKIE['oid'])) ) {
	$conn = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
	mysql_select_db(MYSQL_DB) or die('$APP_NAME database selection error');
	$id = mysql_real_escape_string(strip_tags($_COOKIE['id']));
	$oid = mysql_real_escape_string(strip_tags($_COOKIE['oid']));
	$q = 'SELECT openid FROM '.USER_TABLE.' WHERE (id="'.$id.'")';
	$result = mysql_query($q);
	if (mysql_num_rows($result) == 1) {
		$row = mysql_fetch_array($result);
		if (sha1($row['openid']) == $oid ) { 
			$_SESSION['SESS_ID'] = $id; 
	                $_SESSION['sortitem']='id';
	                $_SESSION['sortorder']='';
	                $_SESSION['limit']='10';
		}
	}
	mysql_close($conn);
}
?>
		<br/><a href="<?php echo INSTALL_PATH; ?>"><img src="<?php echo INSTALL_PATH; ?>logo.png" border="0"><img src="<?php echo INSTALL_PATH; ?>spacer.png" border="0" <?php if (isset($_SESSION['SESS_ID'])) { echo 'width="185px"'; } else { echo 'width="50px"'; } ?>height="0px"></a>
<script type="text/javascript" src="includes/ZeroClipboard.js"></script>
<?php 
if (isset($_SESSION['SESS_ID'])) {  
	echo '<a href="'.INSTALL_PATH.'manage.php">Manage</a>&nbsp;&nbsp;-&nbsp;&nbsp; <a href="'.INSTALL_PATH.'login.php?logoff">Logoff</a>';  
} else { 
        echo '<form id="loginform" name="loginform" action="login.php" method="post">';
        echo '<input type="submit" name="submit" value="Login with Google" style="background:none;border:0;padding:0;font-weight:bold;color:#09c"><br />';
        echo '<input type="checkbox" name="remember" VALUE="1"><label for="remember">Remember login?&nbsp;</label></form>';
//	echo '<form id="loginform" name="loginform" action="login.php" method="post">';
//	echo '<input type="checkbox" name="remember" VALUE="1"><label for="remember">Remember login?</label>&nbsp;&nbsp;';
//	echo '<a href="javascript:submit()">Login with Google</a></form>'; 
} 
?>

